package presentacion;
import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JInternalFrame;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.JLabel;
import javax.swing.JFormattedTextField;
import javax.swing.JButton;
import javax.swing.JTextPane;
import javax.swing.JEditorPane;
import javax.swing.JComboBox;
import javax.swing.DefaultComboBoxModel;
import javax.swing.border.BevelBorder;
import javax.swing.table.DefaultTableModel;

import java.awt.Color;

import javax.swing.JScrollPane;
import javax.swing.JTable;

import java.awt.GridLayout;
import java.awt.GridBagLayout;
import java.awt.GridBagConstraints;
import java.awt.Insets;

import javax.swing.BoxLayout;

import java.awt.Component;
import java.awt.Font;

import javax.swing.SwingConstants;
import static biblioteca.FuncionesDeVentanas.*;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.BorderLayout;


public class Ventas extends JInternalFrame {
	private JTextField textFieldNumeroFactura;
	private JTextField textFieldUsuario;
	private JTextField textFieldTerminalNo;
	private JTextField textFieldUltimaFactura;
	private JTextField textFieldMuestraValor;
	private JPanel panel;
	private JPanel panelDatosCliente;
	private JFormattedTextField formattedTextFieldFechaFactura;
	private JButton btnBuscarCliente;
	private JFormattedTextField formattedTextFieldCedulaCliente;
	private JPanel panelTerminos;
	private JComboBox comboBox;
	private JEditorPane editorPane;
	private JPanel panelDetalle;
	private DefaultTableModel modeloTablaVenta;
	private JPanel panelBotonesVenta;
	private JButton btnAceptar;
	private JButton btnContador;
	private JButton btnCredito;
	private JButton btnAnularFactura;
	private JButton btnBorrarArticulo;
	private JButton btnRetornar;
	private JPanel panelMuestraTotal;
	
	private JTextField textFieldNombreCliente;
	private JTextField textFieldDireccionCliente;
	private JTextField textFieldTelefonoCliente;
	private JTextField textFieldNumeroCliente;
	private JButton btnBuscarArticulo;
	private JScrollPane scrollPane;
	private JTable table;
	

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try 
				{
					Ventas frame = new Ventas();
					frame.setVisible(true);
				} 
				catch (Exception e) 
				{
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public Ventas() {
		setIconifiable(true);
		setMaximizable(true);
		setClosable(true);
		setTitle("Venta");
		setBounds(100, 100, 779, 541);
		getContentPane().setLayout(null);
		
		quitarBotonEsquinaIzquierdaJInternalFrame(this);
		
		panel = new JPanel();
		panel.setBorder(new BevelBorder(BevelBorder.RAISED, Color.GRAY, null, null, null));
		panel.setBounds(10, 0, 743, 39);
		getContentPane().add(panel);
		panel.setLayout(null);
		
		textFieldNumeroFactura = new JTextField();
		textFieldNumeroFactura.setBounds(109, 11, 86, 20);
		panel.add(textFieldNumeroFactura);
		textFieldNumeroFactura.setColumns(10);
		
		JLabel lblNumeroFactura = new JLabel("Numero Factura");
		lblNumeroFactura.setBounds(10, 14, 97, 14);
		panel.add(lblNumeroFactura);
		
		JLabel lblUsuario = new JLabel("Usuario");
		lblUsuario.setBounds(207, 14, 86, 14);
		panel.add(lblUsuario);
		
		textFieldUsuario = new JTextField();
		textFieldUsuario.setColumns(10);
		textFieldUsuario.setBounds(254, 11, 86, 20);
		panel.add(textFieldUsuario);
		
		JLabel lblterminalNo = new JLabel("Terminal No.");
		lblterminalNo.setBounds(352, 14, 86, 14);
		panel.add(lblterminalNo);
		
		textFieldTerminalNo = new JTextField();
		textFieldTerminalNo.setColumns(10);
		textFieldTerminalNo.setBounds(427, 11, 37, 20);
		panel.add(textFieldTerminalNo);
		
		JLabel lblUltimaFactura = new JLabel("Ultima Factura");
		lblUltimaFactura.setBounds(476, 14, 91, 14);
		panel.add(lblUltimaFactura);
		
		textFieldUltimaFactura = new JTextField();
		textFieldUltimaFactura.setColumns(10);
		textFieldUltimaFactura.setBounds(565, 11, 86, 20);
		panel.add(textFieldUltimaFactura);
		
		panelDatosCliente = new JPanel();
		panelDatosCliente.setBorder(new BevelBorder(BevelBorder.RAISED, Color.GRAY, null, null, null));
		panelDatosCliente.setBounds(10, 50, 349, 138);
		getContentPane().add(panelDatosCliente);
		panelDatosCliente.setLayout(null);
		
		JLabel lblFechaFactura = new JLabel("Fecha");
		lblFechaFactura.setBounds(70, 13, 39, 17);
		panelDatosCliente.add(lblFechaFactura);
		
		formattedTextFieldFechaFactura = new JFormattedTextField();
		formattedTextFieldFechaFactura.setBounds(113, 11, 67, 20);
		panelDatosCliente.add(formattedTextFieldFechaFactura);
		
		JLabel lblNumeroDeCliente = new JLabel("Numero de Cliente");
		lblNumeroDeCliente.setBounds(6, 37, 113, 14);
		panelDatosCliente.add(lblNumeroDeCliente);
		
		btnBuscarCliente = new JButton("...");
		btnBuscarCliente.setBounds(180, 33, 33, 23);
		panelDatosCliente.add(btnBuscarCliente);
		
		formattedTextFieldCedulaCliente = new JFormattedTextField();
		formattedTextFieldCedulaCliente.setBounds(218, 34, 103, 20);
		panelDatosCliente.add(formattedTextFieldCedulaCliente);
		
		JLabel lblRnccedula = new JLabel("RNC/Cedula");
		lblRnccedula.setBounds(218, 13, 83, 14);
		panelDatosCliente.add(lblRnccedula);
		
		JLabel lblNombreCliente = new JLabel("Nombre");
		lblNombreCliente.setBounds(61, 63, 48, 14);
		panelDatosCliente.add(lblNombreCliente);
		
		JLabel lblDireccionCliente = new JLabel(" Direccion");
		lblDireccionCliente.setBounds(51, 89, 58, 14);
		panelDatosCliente.add(lblDireccionCliente);
		
		JLabel lblTelefonoCliente = new JLabel("Telefono");
		lblTelefonoCliente.setBounds(61, 115, 48, 14);
		panelDatosCliente.add(lblTelefonoCliente);
		
		textFieldNombreCliente = new JTextField();
		textFieldNombreCliente.setColumns(10);
		textFieldNombreCliente.setBounds(113, 60, 208, 20);
		panelDatosCliente.add(textFieldNombreCliente);
		
		textFieldDireccionCliente = new JTextField();
		textFieldDireccionCliente.setColumns(10);
		textFieldDireccionCliente.setBounds(113, 87, 208, 20);
		panelDatosCliente.add(textFieldDireccionCliente);
		
		textFieldTelefonoCliente = new JTextField();
		textFieldTelefonoCliente.setColumns(10);
		textFieldTelefonoCliente.setBounds(113, 112, 208, 20);
		panelDatosCliente.add(textFieldTelefonoCliente);
		
		textFieldNumeroCliente = new JTextField();
		textFieldNumeroCliente.setColumns(10);
		textFieldNumeroCliente.setBounds(113, 34, 67, 20);
		panelDatosCliente.add(textFieldNumeroCliente);
		
		panelTerminos = new JPanel();
		panelTerminos.setBorder(new BevelBorder(BevelBorder.RAISED, Color.GRAY, null, null, null));
		panelTerminos.setBounds(379, 50, 374, 138);
		getContentPane().add(panelTerminos);
		panelTerminos.setLayout(null);
		
		JLabel lblVendedor = new JLabel("Nota");
		lblVendedor.setBounds(10, 39, 58, 14);
		panelTerminos.add(lblVendedor);
		
		editorPane = new JEditorPane();
		editorPane.setBounds(10, 64, 354, 63);
		panelTerminos.add(editorPane);
		
		JLabel lblTerminos = new JLabel("Terminos");
		lblTerminos.setBounds(10, 11, 58, 16);
		panelTerminos.add(lblTerminos);
		
		comboBox = new JComboBox();
		comboBox.setModel(new DefaultComboBoxModel(new String[] {"Contado", "Credito"}));
		comboBox.setBounds(70, 9, 114, 20);
		panelTerminos.add(comboBox);
		
		btnBuscarArticulo = new JButton("Buscar Articulo");
		btnBuscarArticulo.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
						
			}
		});
		btnBuscarArticulo.setBounds(196, 5, 110, 28);
		panelTerminos.add(btnBuscarArticulo);
		
		panelDetalle = new JPanel();
		panelDetalle.setBorder(new BevelBorder(BevelBorder.RAISED, Color.GRAY, null, null, null));
		panelDetalle.setBounds(10, 200, 743, 175);
		getContentPane().add(panelDetalle);
		panelDetalle.setLayout(new BorderLayout(0, 0));
		
		scrollPane = new JScrollPane();
		panelDetalle.add(scrollPane, BorderLayout.CENTER);
		
		table = new JTable();
		table.setModel(new DefaultTableModel(
			new Object[][] {
				{null, null, null, null, null, null},
				{null, null, null, null, null, null},
				{null, null, null, null, null, null},
				{null, null, null, null, null, null},
				{null, null, null, null, null, null},
				{null, null, null, null, null, null},
				{null, null, null, null, null, null},
				{null, null, null, null, null, null},
				{null, null, null, null, null, null},
				{null, null, null, null, null, null},
				{null, null, null, null, null, null},
				{null, null, null, null, null, null},
				{null, null, null, null, null, null},
				{null, null, null, null, null, null},
				{null, null, null, null, null, null},
				{null, null, null, null, null, null},
				{null, null, null, null, null, null},
				{null, null, null, null, null, null},
				{null, null, null, null, null, null},
				{null, null, null, null, null, null},
				{null, null, null, null, null, null},
				{null, null, null, null, null, null},
				{null, null, null, null, null, null},
				{null, null, null, null, null, null},
				{null, null, null, null, null, null},
				{null, null, null, null, null, null},
				{null, null, null, null, null, null},
				{null, null, null, null, null, null},
				{null, null, null, null, null, null},
				{null, null, null, null, null, null},
				{null, null, null, null, null, null},
				{null, null, null, null, null, null},
				{null, null, null, null, null, null},
				{null, null, null, null, null, null},
				{null, null, null, null, null, null},
				{null, null, null, null, null, null},
				{null, null, null, null, null, null},
				{null, null, null, null, null, null},
				{null, null, null, null, null, null},
				{null, null, null, null, null, null},
				{null, null, null, null, null, null},
				{null, null, null, null, null, null},
				{null, null, null, null, null, null},
				{null, null, null, null, null, null},
				{null, null, null, null, null, null},
				{null, null, null, null, null, null},
				{null, null, null, null, null, null},
				{null, null, null, null, null, null},
				{null, null, null, null, null, null},
				{null, null, null, null, null, null},
			},
			new String[] {
				"Codigo", "Cantidad", "Descripcion", "Precio", "ITBIS", "Importe"
			}
		));
		table.getColumnModel().getColumn(2).setPreferredWidth(80);
		scrollPane.setViewportView(table);
		
		modeloTablaVenta = new DefaultTableModel();
		modeloTablaVenta.addColumn("Codigo");
		modeloTablaVenta.addColumn("Cantidad");
		modeloTablaVenta.addColumn("Descripcion");
		modeloTablaVenta.addColumn("Precio");
		modeloTablaVenta.addColumn("ITBIS");
		modeloTablaVenta.addColumn("Importe");
		modeloTablaVenta.setRowCount(50);
	
		panelBotonesVenta = new JPanel();
		panelBotonesVenta.setBorder(new BevelBorder(BevelBorder.RAISED, Color.GRAY, null, null, null));
		panelBotonesVenta.setBounds(6, 387, 308, 63);
		getContentPane().add(panelBotonesVenta);
		panelBotonesVenta.setLayout(null);
		
		btnAceptar = new JButton("Aceptar");
		btnAceptar.setBounds(10, 3, 75, 28);
		panelBotonesVenta.add(btnAceptar);
		
		btnContador = new JButton("Contado");
		btnContador.setBounds(10, 30, 75, 28);
		panelBotonesVenta.add(btnContador);
		
		btnCredito = new JButton("Credito");
		btnCredito.setBounds(87, 30, 89, 28);
		panelBotonesVenta.add(btnCredito);
		
		btnAnularFactura = new JButton("Anular Fact");
		btnAnularFactura.setBounds(87, 3, 89, 28);
		panelBotonesVenta.add(btnAnularFactura);
		
		btnBorrarArticulo = new JButton("Borrar Articulo");
		btnBorrarArticulo.setBounds(181, 3, 105, 28);
		panelBotonesVenta.add(btnBorrarArticulo);
		
		btnRetornar = new JButton("Retornar");
		btnRetornar.setBounds(181, 30, 105, 28);
		panelBotonesVenta.add(btnRetornar);
		
		panelMuestraTotal = new JPanel();
		panelMuestraTotal.setBorder(new BevelBorder(BevelBorder.RAISED, Color.BLACK, null, null, null));
		panelMuestraTotal.setBounds(326, 387, 427, 68);
		getContentPane().add(panelMuestraTotal);
		panelMuestraTotal.setLayout(null);
		
		textFieldMuestraValor = new JTextField();
		textFieldMuestraValor.setHorizontalAlignment(SwingConstants.RIGHT);
		textFieldMuestraValor.setFont(new Font("SansSerif", Font.BOLD | Font.ITALIC, 47));
		textFieldMuestraValor.setEditable(false);
		textFieldMuestraValor.setText("0.00");
		textFieldMuestraValor.setBounds(108, 0, 319, 67);
		panelMuestraTotal.add(textFieldMuestraValor);
		textFieldMuestraValor.setColumns(10);
		
		JLabel lblValorBruto = new JLabel("Valor Bruto ==>");
		lblValorBruto.setFont(new Font("SansSerif", Font.BOLD | Font.ITALIC, 13));
		lblValorBruto.setBounds(6, 22, 99, 16);
		panelMuestraTotal.add(lblValorBruto);
		desabilitar();
		
	}
	
	public void desabilitar()
	{
		
		
	}
}
